package com.bluetoothsms.common;

public class MessageStatus extends BluetoothMessage {

	public final static int SMS_SENT_SUCCESS = 1;
	public final static int SMS_SENT_ERROR = 0;
	public final static int SMS_SENT_NO_SERVICE = 2;
	public final static int SMS_SENT_NULL_PDU = 3;
	public final static int SMS_SENT_RADIO_OFF = 4;

	public final static int SMS_DELIVERED_SUCCESS = 1;
	public final static int SMS_DELIVERED_ERROR = 0;

	public enum StatusType {
		Alive, SmsSent, SmsDelivered, SmsReceived, Unknown
	}

	public MessageStatus(StatusType type) {
		this(type, -1);
	}

	public MessageStatus(StatusType type, int value) {
		super(BtMessageType.Status, new String[] {
				String.valueOf(type.ordinal()), String.valueOf(value) });
	}

	public MessageStatus(byte[] data, int length) {
		super(BtMessageType.Status, data, length);
	}

	public StatusType getType() {
		if (mData[0] != null) {
			int idx = Integer.valueOf(mData[0]);
			StatusType[] values = StatusType.values();

			if (idx >= 0 && idx < values.length)
				return values[idx];
		}

		return StatusType.Unknown;
	}

	public int getValue() {
		if (mData[1] != null)
			return Integer.valueOf(mData[1]);

		return -1;
	}
}
